import http from "../http"

type LoginParm = {
    username: string,
    password: string,
    role: string
}

type RegisterParm = {
    username: string,
    password: string,
    confirmPassword: string,
    // role: string,
    // email?: string,
    // phone?: string,
    // nickname?: string
}

type ResetPasswordParm = {
    username: string;          // 用户名
    newPassword: string;       // 新密码
    confirmPassword: string;   // 确认新密码
    // verificationCode?: string; // 可选：验证码
};

export const loginApi = (parm: LoginParm) => {
    return http.post("/api/user/login", parm)
}

export const registerApi = (parm: RegisterParm) => {
    return http.post("/api/user/register", parm, {
        headers: {
            'Content-Type': 'application/json' // 明确指定JSON格式
        }
    })
}

export const resetPasswordApi = (parm: ResetPasswordParm) => {
    return http.post("/api/user/reset-password", parm, {
        headers: {
            'Content-Type': 'application/json'
        }
    });
};

